<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>订单退款申请审核</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link th:href="@{/layui/css/layui.css}" rel="stylesheet" />
    <link th:href="@{/iconfont/iconfont.css}" rel="stylesheet" />
    <link th:href="@{/css/custom.layui.css}" rel="stylesheet" />
    <link th:href="@{/css/style.css}" rel="stylesheet" />
    <link th:href="@{/css/genericPage.css}" rel="stylesheet" />
</head>
<body class="eyc-dialog-content">
<form id="aduitOrderForm" lay-filter="aduitOrderForm" class="layui-form" autocomplete="off">
    <div class="layui-row layui-col-space30">
        <div class="layui-col-xs12">
            <div class="layui-form-item">
                <label class="layui-form-label eyc-required">备注:</label>
                <textarea id="auditRemark" class="layui-input eyc-uppercase" name="auditRemark" type="text"  style="resize: none;height: 120px !important;line-height: normal !important;"></textarea>
            </div>
        </div>

    </div>
    <div class="layui-row">
        <div class="layui-col-sm12 eyc-text-align-right">
            <button type="button"  onclick="agreeRefund();"
                    class="layui-btn layui-btn-sm layui-btn-primary layui-border-orange">
                <i class="icon iconfont icon-save"></i><span>同意</span>
            </button>
            <button type="button" onclick="rejectRefund();"
                    class="layui-btn layui-btn-sm layui-btn-primary layui-border-red">
                <i class="icon iconfont icon-close"></i><span>拒绝</span>
            </button>
        </div>
    </div>
    <script th:src="@{/js/jquery.min.js}"></script>
    <script th:src="@{/layui/layui.js}"></script>
    <script th:src="@{/js/genericPage.js}"></script>
    <script>
        let eycOrder=null;
        $(function() {
            layui.use(['form'], function () {

            });
let agreeRefund=function(){
    let auditRemark=$('#auditRemark').val();
    if(!auditRemark){
        parent.layer.msg('请填写备注~~');
        return ;
    }
    let refundParams = {
        totalFee: 1/*eycOrder.price * 100*/,
        refundFee: 1,
        openid: eycOrder.openid,
        outTradeNo: eycOrder.orderNum,
        outRefundNo: eycOrder.orderId,
        opUserId: eycOrder.orderNum,
        refundDesc:auditRemark
    };
    eyc.ajax.promise('/wechat/pay/refund',refundParams).then(res=>{
        if(res.data){
            parent.layer.msg('退款成功~~');
            parent.contabs.getActivePageWin().refreshData();
            closeWin();
        }
    });
};
            let initData=function (rowData) {
                eycOrder=rowData;
                eyc.ui.setValueUiElement($('#aduitOrderForm'),eycOrder);
            };
            let closeWin=function (){
                let index = parent.layer.getFrameIndex(window.name); // 获取当前窗体索引
                parent.layer.close(index); // 执行关闭
            }
            // 关闭
            let rejectRefund=function () {
                let auditRemark=$('#auditRemark').val();
                if(!auditRemark){
                    parent.layer.msg('请填写备注~~');
                    return ;
                }
                eycOrder.auditRemark=auditRemark;
                eyc.ajax.promise('/eyc/auditRejectOrder',eycOrder).then(res=> {
                    if(res.data) {
                        parent.layer.msg('保存成功~~');
                        parent.contabs.getActivePageWin().refreshData();
                        closeWin();
                    }
                });
            };
            window.initData=initData;
            window.rejectRefund=rejectRefund;
            window.agreeRefund=agreeRefund;
        });

    </script>
</form>
</body>